package com.wm.ad_navi_new.ui.fragment

import android.view.View
import androidx.fragment.app.Fragment
import androidx.viewpager2.widget.ViewPager2
import com.wm.ad_navi_new.R
import com.wm.ad_navi_new.adapter.ViewPager2Adapter
import com.wm.ad_navi_new.base.BaseFragment

class SettingFragment: BaseFragment() {

    private lateinit var viewPager2: ViewPager2

    private lateinit var adapter: ViewPager2Adapter

    private val fragments = mutableListOf<Fragment>()

    override fun setLayoutID(): Int {
        return R.layout.fragment_setting
    }

    override fun initView(view: View) {
        viewPager2 = view.findViewById(R.id.view_pager2)
    }

    override fun initData() {
        initViewPager2()
    }

    /**
     * 初始化 ViewPager2
     */
    private fun initViewPager2() {
        fragments.add(NavigationSettingFragment())
        fragments.add(BroadCastFragment())
        fragments.add(MapSettingFragment())
        fragments.add(OtherFragment())

        adapter = ViewPager2Adapter(fragmentActivity = requireActivity(), fragments)
        viewPager2.adapter = adapter

        viewPager2.orientation = ViewPager2.ORIENTATION_VERTICAL

        viewPager2.offscreenPageLimit = fragments.size


    }


}